<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<div>
	<logic:present name="search_vo" property="trainNumber">
		<c:choose>
			<c:when test="${search_vo.trainNumber eq ''}">
				<p align="center" style="margin: 20px 0;">请在查询框内输入车次信息...</p>
			</c:when>
			<c:otherwise>
				<bean:define id="high_speed" value="${fn:startsWith(fn:toUpperCase(search_vo.trainNumber), 'D') or fn:startsWith(fn:toUpperCase(search_vo.trainNumber), 'G') ? 1 : 0}" />
				<p class="nav_result">车次<label class="redb" style="margin:0 5px;">${search_vo.trainNumber}</label>的详细信息如下：<logic:present name="result.page"><logic:iterate name="result.page" property="items" id="entity">(最近更新 ${entity.trainLastUpdate})</logic:iterate></logic:present></p>
				<table width="100%" cellpadding="0" cellspacing="0" border="1" style="text-align:center;" class="datagrid">
					<thead>
						<tr bgcolor="#c1e8af"> 
							<td>车次</td>
							<td>站次</td>
							<td>站名</td>
							<td>到达时间</td>
							<td>开车时间</td>
							<td>运行时间</td>
							<td>里程</td>
							<c:if test="${high_speed eq 0}">
							<td>硬座</td>
							<td>软座价</td>
							</c:if>
							<td>硬卧上/中/下</td>
							<td>软卧上/下</td>
							<c:if test="${high_speed eq 1}">
							<td>二等/一等软座</td>
							</c:if>
							<td class="side"></td>
						</tr>
					</thead>
						<logic:present name="result.page">
							<logic:iterate name="result.page" property="items" id="entity">
								<logic:present name="entity" property="trainSchedules">
									<logic:iterate name="entity" property="trainSchedules" id="schedule" indexId="idx">
										<tr <c:if test="${idx % 2 == 1}">bgcolor="#fafbf5"</c:if>>
											<td>${entity.trainNumber}</td>
											<td>${schedule.trainStationSeq}</td>
											<td><a style="text-decoration: underline;" href="app/train/search?station=${schedule.trainStationName}">${schedule.trainStationName}</a></td>
											<td>${schedule.trainArriveTime}</td>
											<td>${schedule.trainDepartureTime}</td>
											<td>${schedule.trainRuntime}</td>
											<td>${schedule.trainRange}</td>
											<c:if test="${high_speed eq 0}">
											<td>${fn:length(fn:trim(schedule.trainPriceHardSeat)) ne 0 ? schedule.trainPriceHardSeat : '-'}</td>
											<td>${fn:length(fn:trim(schedule.trainPriceSoftSeat)) ne 0 ? schedule.trainPriceSoftSeat : '-'}</td>
											</c:if>
											<td>${schedule.trainPriceHardBerthTop}/${schedule.trainPriceHardBerthMiddle}/${schedule.trainPriceHardBerthLow}</td>
											<td>${schedule.trainPriceSoftBerthTop}/${schedule.trainPriceSoftBerthLow}</td>
											<c:if test="${high_speed eq 1}">
											<td>${schedule.trainPriceSoftLv2nd}/${schedule.trainPriceSoftLv1st}</td>
											</c:if>
											<form name="myform" id="myform" action="app/order_build" method="post">
											<input type="hidden" name="from" value="${entity.trainStationStarting}"/>
											<input type="hidden" name="to" value="${schedule.trainStationName}"/>
											<input type="hidden" name="code" value="${entity.trainNumber}"/>
											<td class="side"><c:if test="${idx > 0}">
											<input  style="font-color:blue;" onclick="if(${sessionScope.USER==null}) alert('请先登录！');else{submit();}" type="button" value="买票" />
											</c:if></td>
											</form>
										</tr>
									</logic:iterate>
								</logic:present>
							</logic:iterate>
						</logic:present>
					<tbody>
					</tbody>
				</table>
			</c:otherwise>
		</c:choose>
	</logic:present>
</div>